<!-- 角色配置 -->
<div class="easyui-layout" data-options="fit:true,border:false">
    <div id="mainContent" data-options="region:'north',border:false" >
        <div class="searchIndex">
            <ul>
                <li>
                    <label>关键字:</label>
                    <input id="txtQueryRoleName" name="txtQueryRoleName" class="base-input" style="width:150px;">
                </li>
                <li>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-searchWin8',plain:true" onclick="queryRolesByName()">查询</a>
                </li>
            </ul>
        </div>
    </div>
    <div data-options="region:'center',border:false" class="paginColor">
        <div id="configurationButton" style="padding-left:10px;">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add-win8',plain:true" onclick="showNewRole();">新增</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-trackRecordwin8',plain:true" onclick="showEditRole()">修改</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-searchWin8',plain:true" onclick="showRoleView()">查看</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-removeWin8',plain:true" onclick="deleteRoles()">删除</a>
        </div>
        <table id="tblQueryRoleList" class="easyui-datagrid" 
        data-options="toolbar:'#configurationButton',pagination:true,fit:true,autoRowHeight:false,rownumbers:true, border:false,fitColumns:true,singleSelect:false, url:'',pageNumber:1">
            <thead>
                <tr>
                    <th data-options="field:'id',hidden:true"></th>    
                    <th data-options="field:'code',width:100,align:'center'">角色代码</th>                                                      
                    <th data-options="field:'name',width:100,align:'center'">角色名称</th>                                                    
                    <th data-options="field:'description',width:100,align:'center'">角色描述</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

<div id="addrole" class="easyui-dialog" 
    data-options="
        title:'新增角色',
        closed:true,
        modal:true,
        height:500,
        width:1000">
    <div id="gridBtn" class="con_form">
        <ul>
            <li>
                <label>角色代码:</label>
                <input id="txtRoleCode" name="txtRoleCode" 
                 class="easyui-validatebox base-input" 
                 style="width:150px;" data-options="required:true" onblur="existsRole();" maxlength="13">
            </li>
            <li>
                <label>角色名称:</label>
                <input id="txtRoleName" name="txtRoleName" 
                 class="easyui-validatebox base-input" 
                 style="width:150px;" data-options="required:true" maxlength="13">
            </li>
            <li>
                <label>角色描述:</label>
                <input id="txtRoleDesc" name="txtRoleDesc" 
                 class="easyui-validatebox base-input" 
                 style="width:250px;" maxlength="30">
            </li>
            <li>
                <a href="javascript:void(0);" class="easyui-linkbutton  okButton" data-options="iconCls:'icon-okWin8'" onclick="saveRole()">确认</a>
            </li>
        </ul>
    </div>
    <table id="tblAuthorityList" class="easyui-datagrid" data-options="toolbar:'#gridBtn',rownumbers:true,border:false,fit:true,fitColumns:true,singleSelect:false,nowrap:false,pagination:false,url:'',queryParams:{name:''},height:280">   
        <thead>
            <tr>
                <th data-options="field:'code',width:100,align:'center'">权限代码</th>
                <th data-options="field:'name',width:100,align:'center'">权限名称</th>   
                <th data-options="field:'description',width:100,align:'center'">权限描述</th>   
            </tr>
        </thead>
    </table>
</div>

<script type="text/javascript">
    function showNewRole(){
        
        $("#txtRoleCode").val("");
        $("#txtRoleName").val("").validatebox('validate');
        $("#txtRoleDesc").val("");
        $('#tblAuthorityList').datagrid('unselectAll');
        //去掉按Enter键事件
        document.onkeydown = "";
        // openDialog("#addrole");
        $('#addrole').dialog('open');
        // setFocus($("#txtRoleCode"));
    }

    function selectAuthorityRows(data){
        
        var rows=$("#editTblAuthorityList").datagrid("getRows");
        if(rows){
           for(var i=rows.length-1;i>=0;i--){
               
               if(rows[i].selected==true){        
                  var rowIndex=$("#editTblAuthorityList").datagrid("getRowIndex",rows[i]);
                  $("#editTblAuthorityList").datagrid("selectRow",rowIndex);
               }
           }
        }
    }
</script>